import Axios from 'axios';
import { constants, cofirmAction } from './actionTypes';

const {keboApi, types} = constants;

export const actions = {
    //获取首页数据
    [cofirmAction.UPDATE_HOME_DATA]() {
        Axios({
            method: 'GET',
            
            url: keboApi + types.TAILINGPOND.type + types.TAILINGPOND.OPERATIONGSTATUS
        }).then( res => {
            console.log(res)
        } )
    },
    //获取左侧列表
    [cofirmAction.UPDATE_LEFTMENU]({ commit }) {
        Axios({
            method: 'get',
            url: keboApi + types.MENUTREE.type + types.MENUTREE.MENUTREEDATA
        }).then( res => {
            console.log(res)
            commit('updateLeftMenu', res.data.parameter)
        })
    },
    //传感器类型
    [cofirmAction.UPDATE_MONTORTYPE]({ commit }) {
        Axios({
            method: 'get',
            url: keboApi + types.MONITORPOINT.type + types.MONITORPOINT.MONITORTYPELIST
        }).then(res => {
            console.log(res)
            commit('updateMonitorTypeList', res.data.parameter)
        })
    },
    //传感器
    [cofirmAction.UPDATE_MONITORLIST]({ commit }, queryData) {
        console.log(queryData)
        Axios({
            method: 'get',
            url: keboApi + types.MONITORPOINT.type + types.MONITORPOINT.MONITORLIST + "?monitorTypeId=" + queryData.monitorTypeId + "&tailingPondId=" + queryData.tailingPondId
        }).then(res => {
            console.log(res)
            commit('updateMonitorList', res.data.parameter)
        })
    },
    [cofirmAction.UPDATE_MONITORCHART]({ commit }, queryData) {
        console.log(queryData)
        Axios({
            method: 'get',
            url: keboApi + types.MONITORPOINT.type + types.MONITORPOINT.MONITORLIST + "?monitorTypeId=" + queryData.monitorTypeId + "&tailingPondId=" + queryData.tailingPondId
        }).then(res => {
            console.log(res)
            commit('updateMonitorList', res.data.parameter)
        })
    }
}